package com.yipei.business.controller;

import com.yipei.business.domain.MlTradeAccountFinancingApply;
import com.yipei.business.service.IMlTradeAccountFinancingApplyService;
import com.yipei.common.annotation.Log;
import com.yipei.common.core.controller.BaseController;
import com.yipei.common.core.domain.AjaxResult;
import com.yipei.common.core.page.TableDataInfo;
import com.yipei.common.enums.BusinessType;
import com.yipei.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 融资申请Controller
 *
 * @author yipei
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/business/financingapply")
@Api(tags = "融资申请", description = "融资申请")
public class MlTradeAccountFinancingApplyController extends BaseController {
    @Autowired
    private IMlTradeAccountFinancingApplyService mlTradeAccountFinancingApplyService;

    /**
     * 查询融资申请列表
     */
    @PreAuthorize("@ss.hasPermi('business:financingapply:list')")
    @ApiOperation("融资申请获取数据")
    @GetMapping("/list")
    public TableDataInfo list(MlTradeAccountFinancingApply mlTradeAccountFinancingApply) {
        startPage();
        List<MlTradeAccountFinancingApply> list = mlTradeAccountFinancingApplyService.selectMlTradeAccountFinancingApplyList(mlTradeAccountFinancingApply);
        return getDataTable(list);
    }

    /**
     * 导出融资申请列表
     */
    @PreAuthorize("@ss.hasPermi('business:financingapply:export')")
    @ApiOperation("融资申请导出数据")
    @Log(title = "融资申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MlTradeAccountFinancingApply mlTradeAccountFinancingApply) {
        List<MlTradeAccountFinancingApply> list = mlTradeAccountFinancingApplyService.selectMlTradeAccountFinancingApplyList(mlTradeAccountFinancingApply);
        ExcelUtil<MlTradeAccountFinancingApply> util = new ExcelUtil<MlTradeAccountFinancingApply>(MlTradeAccountFinancingApply.class);
        util.exportExcel(response, list, "融资申请数据");
    }

    /**
     * 获取融资申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:financingapply:query')")
    @ApiOperation("融资申请通过ID获取数据")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mlTradeAccountFinancingApplyService.selectMlTradeAccountFinancingApplyById(id));
    }

    /**
     * 新增融资申请
     */
    @PreAuthorize("@ss.hasPermi('business:financingapply:add')")
    @ApiOperation("融资申请新增数据")
    @Log(title = "融资申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MlTradeAccountFinancingApply mlTradeAccountFinancingApply) {
        return toAjax(mlTradeAccountFinancingApplyService.insertMlTradeAccountFinancingApply(mlTradeAccountFinancingApply));
    }

    /**
     * 修改融资申请
     */
    @PreAuthorize("@ss.hasPermi('business:financingapply:edit')")
    @ApiOperation("融资申请修改数据")
    @Log(title = "融资申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MlTradeAccountFinancingApply mlTradeAccountFinancingApply) {
        return toAjax(mlTradeAccountFinancingApplyService.updateMlTradeAccountFinancingApply(mlTradeAccountFinancingApply));
    }

    /**
     * 删除融资申请
     */
    @PreAuthorize("@ss.hasPermi('business:financingapply:remove')")
    @ApiOperation("融资申请删除数据")
    @Log(title = "融资申请", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mlTradeAccountFinancingApplyService.deleteMlTradeAccountFinancingApplyByIds(ids));
    }
}
